package com.ruoyi.datastatistics.domain;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import com.ruoyi.common.annotation.Excel;
import lombok.ToString;
import org.springframework.format.annotation.NumberFormat;

/**
 * 抄表率对象 copy_rate
 *
 * @author TsingYu
 * @date 2024-08-02
 */
@TableName("t_copy_rate")
@Data
@ToString
public class CopyRate implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 终端类型，大用户表
     */
    public static final int TERMINAL_TYPE_DB = 1;

    /**
     * 终端类型，户表
     */
    public static final int TERMINAL_TYPE_XB = 2;

    /**
     * 终端类型，1：大用户表、2：户表
     */
    @TableField("terminal_type")
    private Integer terminalType;
    /**
     * 区域id
     */
    @TableField("sheets_id")
    private Long sheetsId;

    /**
     * 区域代码
     */
    @Excel(name = "区域代码")
    @TableField("sheets_code")
    private String sheetsCode;

    /**
     * 区域名称
     */
    @Excel(name = "区域名称")
    @TableField("sheets_name")
    private String sheetsName;

    /**
     * 日期
     */
    @Excel(name = "日期", dateFormat = "yyyy-MM-dd")
    @TableField("date")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date date;

    /**
     * 已抄数
     */
    @Excel(name = "已抄数", cellType = Excel.ColumnType.NUMERIC)
    @TableField("copy_count")
    private Integer copyCount;

    /**
     * 应抄数
     */
    @Excel(name = "应抄数", cellType = Excel.ColumnType.NUMERIC)
    @TableField("total_count")
    private Integer totalCount;

    /**
     * 已抄数之和
     */
    @TableField(value = "sum(ifnull(copy_count,0))", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Integer copyCountSum;

    /**
     * 应抄数之和
     */
    @TableField(value = "sum(ifnull(total_count,0))", insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
    private Integer totalCountSum;

    /**
     * 抄表率
     */
    @Excel(name = "抄表率", decimalFormat = 0xa)
    @TableField("copy_rate")
    private BigDecimal copyRate;

    /**
     * 选定范围内的总抄表率
     */
    @Excel(name = "区域总抄表率", decimalFormat = 0xa)
    @TableField(exist = false)
    private BigDecimal totalCopyRate;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    /**
     * 筛选日期-开始
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(exist = false)
    private String beginDate;

    /**
     * 筛选日期-结束
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(exist = false)
    private String endDate;

    /**
     * 筛选抄表率范围最小值
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(exist = false)
    @NumberFormat(style = NumberFormat.Style.PERCENT)
    private BigDecimal copyRateMin;

    /**
     * 筛选抄表率范围最大值
     */
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @TableField(exist = false)
    @NumberFormat(style = NumberFormat.Style.PERCENT)
    private BigDecimal copyRateMax;

    /**
     * 筛选区域id
     */
    @TableField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private List<Long> sheetsIds;
}
